<?php
/* @var $this WordController */
/* @var $model Word */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'word-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'word'); ?>
		<?php echo $form->textField($model,'word',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'word'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'pre'); ?>
		<?php 
	
	$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
	'name'=>'Word[pre]',
	'value'=>"",
//	'source'=>$people, // <- use this for pre-set array of values
	'source'=>CHtml::normalizeUrl(array("prefix/getPrefix")),// <- path to controller which returns dynamic data
	// additional javascript options for the autocomplete plugin
	'options'=>array(
		'minLength'=>'1', // min chars to start search
		'select'=>'js:function(event, ui) { console.log(ui.item.id +":"+ui.item.value);
 		$.ajax({
                                url: "'.CHtml::normalizeUrl(array("prefix/getPreInfo")).'",
                                dataType: "json",
                                data: {                                 
                                    pre: ui.item.value,
                                },
                                success: function (data) {
                                		var s="<option value=0>无</option>";
                                        for(i in data){
                                        	
                                        	s+="<option value="+data[i].id+">"+data[i].value+"</option>"
										}
										$("#preInfoId").html(s);
                                }
                            })
 }'
	),
	'htmlOptions'=>array(
// 		'id'=>'person',
// 		'rel'=>'val',
	
	),
));?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'preInfo'); ?>
		<select id="preInfoId" name="Word[preInfoId]"></select>
		
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'suf'); ?>
		<?php 
		
	$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
	'name'=>'Word[suf]',
	'value'=>"",
//	'source'=>$people, // <- use this for pre-set array of values
	'source'=>CHtml::normalizeUrl(array("suffix/getSuffix")),// <- path to controller which returns dynamic data
	// additional javascript options for the autocomplete plugin
	'options'=>array(
		'minLength'=>'1', // min chars to start search
		'select'=>'js:function(event, ui) {
 		$.ajax({
                                url: "'.CHtml::normalizeUrl(array("suffix/getSufInfo")).'",
                                dataType: "json",
                                data: {                                 
                                    suf: ui.item.value,
                                },
                                success: function (data) {
                                		var s="<option value=0>无</option>";
                                        for(i in data){
                                        	
                                        	s+="<option value="+data[i].id+">"+data[i].value+"</option>"
										}
										$("#sufInfoId").html(s);
                                }
                            })
 }'
	),
	'htmlOptions'=>array(
// 		'id'=>'person',
// 		'rel'=>'val',
	
	),
));?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'sufInfo'); ?>
		<select id="sufInfoId" name="Word[sufInfoId]"></select>
		
	</div>
	<div class="row">
		说明
		<input name="Word[info]">
		
	</div>
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->